package com.wanyang.controller;

import com.wanyang.dto.PrincipalCommentDTO;
import com.wanyang.dto.SubCommentDTO;
import com.wanyang.service.PostCommentService;
import com.wanyang.vo.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags="帖子评论提交api")
@RestController
@RequestMapping("postComment")
public class PostCommentController {

    @Autowired
    private PostCommentService postCommentService;

    @ApiOperation(value = "提交评论 - 帖子1级评论")
    @PostMapping("principal")
    public ApiResult writePrincipalComment(@RequestBody PrincipalCommentDTO principalCommentDTO) {

        return ApiResult.success(postCommentService.writePrincipalComment(principalCommentDTO), null);
    }

    @ApiOperation(value = "提交评论 - 帖子2级评论")
    @PostMapping("sub")
    public ApiResult writeSubComment(@RequestBody SubCommentDTO subCommentDTO) {

        return ApiResult.success(postCommentService.writeSubComment(subCommentDTO), null);
    }

    @ApiOperation(value = "根据帖子id 删除评论")
    @PostMapping("del/{postCommentId}")
    public ApiResult del(@PathVariable Integer postCommentId) {
        postCommentService.deleteComment(postCommentId);
        return ApiResult.success();
    }

}
